// Copyright (C) 2009  Yann de The
// 
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

#include "SEUtil.h"

void getPresentTime(char* date) {
	boost::posix_time::ptime now = boost::posix_time::microsec_clock::universal_time();
	
	std::string Sdate = stringify(now);
    //std::string Sdate("20 August 2011 21:36:48.00");
	size_t length;
	length = Sdate.copy(date, Sdate.size());
	date[length] = '\0';
	//Sdate.copy(date, Sdate.size());
    
}

void UTC_to_str(double epoch, char* str) {
	static char timestamp[30] = "";
    time_t tt = 0;
    memset(timestamp, '\0', 30);
    tt = epoch;
    strftime(timestamp, 30, "%Y-%b-%d %H:%M:", gmtime(&tt));
    
    double integral;
    double fractional = modf(epoch/60., &integral)*60.;
    
    sprintf(str, "%s%f", timestamp, fractional);
    
}

void UTC_to_cockpit_str(double epoch, char* str) {
	static char timestamp[30] = "";
    time_t tt = 0;
    memset(timestamp, '\0', 30);
    tt = epoch;
    strftime(timestamp, 30, "%Y-%b-%d %H:%M:%S", gmtime(&tt));
    
    sprintf(str, "%s", timestamp);
   
}

void disp_mat4(const mat4f& mat) {
    std::cout << mat(0,0) << ",\t" << mat(1,0) << ",\t" << mat(2,0) << ",\t" << mat(3,0) << std::endl;
    std::cout << mat(0,1) << ",\t" << mat(1,1) << ",\t" << mat(2,1) << ",\t" << mat(3,1) << std::endl;
    std::cout << mat(0,2) << ",\t" << mat(1,2) << ",\t" << mat(2,2) << ",\t" << mat(3,2) << std::endl;
    std::cout << mat(0,3) << ",\t" << mat(1,3) << ",\t" << mat(2,3) << ",\t" << mat(3,3) << std::endl;
}


